package com.shop.service.impl;

import com.shop.entity.Membership;
import com.shop.mapper.MembershipMapper;
import com.shop.service.MembershipService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @author XCH
 * @date 2025 - 06 - 09
 */
@Service("membershipService")
@RequiredArgsConstructor
@Transactional(rollbackFor = RuntimeException.class,
        propagation = Propagation.REQUIRED)
public class MembershipServiceImpl implements MembershipService {
    private final MembershipMapper membershipMapper;
    @Override
    public List<Membership> listMembership(Integer id) {
        List<Membership> list = membershipMapper.listMembership(id);
        return new ArrayList<>(list);
    }

    @Override
    public void updateMembership(Membership membership) {
        membershipMapper.updateMembership(membership);

    }

    @Override
    public void updatePoints(Membership membership) {
        membershipMapper.updatePoints(membership);
    }

    @Override
    public void updatePointsAndLevel(Membership membership) {
        membershipMapper.updatePointsAndLevel(membership);
    }
}
